<template>
  <div class="orderimport">
    <!-- 会员查询条件 -->
    <div style="display: flex; margin: 0 0 10px 0">
      <el-form ref="members" :model="members" size="mini" style="display: flex">
        <el-form-item label="姓名" style="display: flex; margin: 0 30px 0 0">
          <el-input :disabled="true" v-model="members.customerName" @blur="insert($event)"></el-input>
        </el-form-item>
        <el-form-item label="手机" style="display: flex; margin: 0 30px 0 0">
          <el-input v-model="members.customerPhone"></el-input>
        </el-form-item>
        <el-form-item label="卡号" style="display: flex; margin: 0 30px 0 0">
          <el-input v-model="members.customerCard"></el-input>
        </el-form-item>
        <el-button size="mini" type="primary" @click="searchorderimport">立即查询</el-button>
      </el-form>
    </div>
    <!-- 去程 -->
    <div style="margin: 40px 0 0 0">
      <div>
        <span style="margin: 0 20px 0 0; font-weight: 900">去程:</span>
        <span style="color: #ea2112">pnr获取的行程不能修改</span>
      </div>
      <div>
        <el-form :model="outbound" :rules="rules" ref="ruleForm" size="mini" class="demo-ruleForm">
          <div style="display:flex;">
            <el-form-item label="航司" prop="name" style="display:flex;">
              <el-input v-model="outbound.airline"></el-input>
            </el-form-item>
            <el-form-item label="出发地机场" prop="name" style="display:flex;">
              <el-input v-model="outbound.setOff"></el-input>
            </el-form-item>
            <el-form-item label="到达地机场" prop="name" style="display:flex;">
              <el-input v-model="outbound.arrive"></el-input>
            </el-form-item>
            <el-form-item label="航班号" prop="name" style="display:flex;">
              <el-input v-model="outbound.flightNumber"></el-input>
            </el-form-item>
          </div>
          <div style="display:flex;">
            <el-form-item label="起飞时间" prop="name" style="display:flex;">
              <el-date-picker v-model="outbound.departureTime" type="datetime" placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="到达时间" prop="arrivalTime" style="display:flex;">
              <el-date-picker v-model="outbound.arrivalTime" type="datetime" placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="舱位" prop="name" style="display:flex;">
              <el-input v-model="outbound.position"></el-input>
            </el-form-item>
          </div>

        </el-form>
      </div>
      <!-- <div style="margin: 10px 0 0 0">
        <i class="el-icon-circle-plus" style="color: #12bf6a"></i>
        <span>添加行程</span>
      </div> -->
    </div>
    <!-- 回程 -->
    <div style="margin: 40px 0 0 0">
      <div>
        <span style="margin: 0 20px 0 0; font-weight: 900">回程:</span>
        <!-- <span style="color: #ea2112">pnr|pnr内容获取的行程不能修改</span> -->
      </div>
      <div>
        <el-form :model="journey" :rules="rules" ref="ruleForm" size="mini" class="demo-ruleForm">
          <div style="display:flex;">
            <el-form-item label="航司" prop="name" style="display:flex;">
              <el-input v-model="journey.airline"></el-input>
            </el-form-item>
            <el-form-item label="出发地机场" prop="name" style="display:flex;">
              <el-input v-model="journey.setOff"></el-input>
            </el-form-item>
            <el-form-item label="到达地机场" prop="name" style="display:flex;">
              <el-input v-model="journey.arrive"></el-input>
            </el-form-item>
            <el-form-item label="航班号" prop="name" style="display:flex;">
              <el-input v-model="journey.flightNumber"></el-input>
            </el-form-item>
          </div>
          <div style="display:flex;">
            <el-form-item label="起飞时间" prop="name" style="display:flex;">
              <el-date-picker v-model="journey.departureTime" type="datetime" placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="到达时间" prop="name" style="display:flex;">
              <el-date-picker v-model="journey.arrivalTime" type="datetime" placeholder="选择日期时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="舱位" prop="name" style="display:flex;">
              <el-input v-model="journey.position"></el-input>
            </el-form-item>
          </div>

        </el-form>
      </div>
      <!-- <div style="margin: 10px 0 0 0">
        <i class="el-icon-circle-plus" style="color: #12bf6a"></i>
        <span>添加行程</span>
      </div> -->
    </div>
    <!-- 乘车人信息循环 -->
    <div v-if="travelerVoList.length>=1">
      <div style="margin: 10px 0 0 0">
        <div>乘机人信息:</div>
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" size="mini" class="demo-ruleForm"
          v-for="(item,index) in travelerVoList" :key='index'>
          <div style="display:flex;">
            <el-form-item label="乘机人姓名" prop="name" style="display:flex;">
              <el-input v-model="item.name"></el-input>
            </el-form-item>
            <el-form-item label="乘机人手机号" prop="name" style="display:flex;">
              <el-input v-model="item.phone"></el-input>
            </el-form-item>
            <el-form-item label="乘机人证件号" prop="name" style="display:flex;">
              <el-input v-model="item.idno"></el-input>
            </el-form-item>
            <el-form-item label="乘机人类型" prop="name" style="display:flex;">
              <el-select clearable v-model="item.type" placeholder="请选择">
                <el-option v-for="item in Passengerstype" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </div>
          <div style="display:flex;">
            <el-form-item label="性别" prop="name" style="display:flex;">
              <el-select clearable v-model="item.sex" placeholder="请选择">
                <el-option v-for="item in gender" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="出生日期" prop="name" style="display:flex;">
              <el-date-picker v-model="item.birthday" size="mini" style="width: 140px" placeholder="选择日期"
                :value-format="format">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="国籍" prop="name" style="display:flex;">
              <el-select clearable v-model="item.citizenship" placeholder="请选择">
                <el-option v-for="item in nationality" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </div>
          <div style="display:flex;">
            <el-form-item label="证件有效期" prop="name" style="display:flex;">
              <el-date-picker v-model="item.documentsDate" size="mini" style="width: 140px" placeholder="选择日期"
                :value-format="format">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="乘客证件类型" prop="name" style="display:flex;">
              <el-select clearable v-model="item.idtype" placeholder="请选择">
                <el-option v-for="item in mold" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="票号" prop="name" style="display:flex;">
              <el-input v-model="item.ticketNum"></el-input>
            </el-form-item>
          </div>
        </el-form>
      </div>
    </div>
    <!-- 乘车人信息手动输入 -->
    <div style="margin: 10px 0 0 0" v-if="travelerVoList.length<1">
      <div>乘机人信息:</div>
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" size="mini" class="demo-ruleForm"
        v-for="(item,index) in arr" :key='index'>
        <div style="display:flex;">
          <el-form-item label="乘机人姓名" prop="name" style="display:flex;">
            <el-input v-model="item.name"></el-input>
          </el-form-item>
          <el-form-item label="乘机人手机号" prop="name" style="display:flex;">
            <el-input v-model="item.phone"></el-input>
          </el-form-item>
          <el-form-item label="乘机人证件号" prop="name" style="display:flex;">
            <el-input v-model="item.idno"></el-input>
          </el-form-item>
          <el-form-item label="乘客类型" prop="name" style="display:flex;">
            <el-select clearable v-model="item.type" placeholder="请选择">
              <el-option v-for="item in Passengerstype" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </div>
        <div style="display:flex;">
          <el-form-item label="性别" prop="name" style="display:flex;">
            <el-select clearable v-model="item.sex" placeholder="请选择">
              <el-option v-for="item in gender" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="出生日期" prop="name" style="display:flex;">
            <el-date-picker v-model="item.birthday" size="mini" style="width: 140px" placeholder="选择日期"
              :value-format="format">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="国籍" prop="name" style="display:flex;">
            <el-select clearable v-model="item.citizenship" placeholder="请选择">
              <el-option v-for="item in nationality" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </div>
        <div style="display:flex;">
          <el-form-item label="证件有效期" prop="name" style="display:flex;">
            <el-date-picker v-model="item.documentsDate" size="mini" style="width: 140px" placeholder="选择日期"
              :value-format="format">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="乘客证件类型" prop="name" style="display:flex;">
            <el-select clearable v-model="item.idtype" placeholder="请选择">
              <el-option v-for="item in mold" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="票号" prop="name" style="display:flex;">
            <el-input v-model="item.ticketNum"></el-input>
          </el-form-item>
        </div>
      </el-form>
    </div>
    <div style="margin: 10px 0 0 0;width:100px;" @click="addRiders">
      <i class="el-icon-circle-plus" style="color: #12bf6a"></i>
      <span>添加乘机人</span>
    </div>
    <div class="middle">
      <!-- 左边 -->
      <div>
        <div style="display:flex;">
          <div style="margin:3px 10px 0 0;width:200px;">PNR:</div>
          <el-input size="mini" v-model="ruleForm.pnr" placeholder="请输入PNR">
          </el-input>
          <el-button type="primary" style="margin:0 0 0 10px" @click="importPNR" size="mini">PNR导入</el-button>
        </div>
        <div style="margin:50px 0 0 0;display:flex;">
          <div style="margin:3px 10px 0 0;width:200px;">大编码:</div>
          <el-input size="mini" v-model="ruleForm.coding" placeholder="请输入大编码">
          </el-input>
        </div>
        <div style="margin:50px 0 0 0;display:flex;">
          <div style="margin:3px 10px 0 0;width:200px;">PNR内容消息:</div>
          <el-input type="textarea" :rows="3" placeholder="请输入PNR内容消息" v-model="ruleForm.pnrcontent">
          </el-input>

        </div>

        <div style="margin:50px 0 0 0;display:flex;">
          <div style="margin:3px 10px 0 0;width:200px;">退改签规则:</div>
          <el-input type="textarea" :rows="1" placeholder="请输入退改签规则" v-model="ruleForm.refundRebook">
          </el-input>

        </div>
        <div style="margin:50px 0 0 0;display:flex;">
          <div style="margin:3px 10px 0 0;width:200px;">行李规则:</div>
          <el-input type="textarea" :rows="1" placeholder="请输入行李规则" v-model="ruleForm.luggage">
          </el-input>
        </div>
      </div>
      <!-- 右边 -->
      <div class="right">
        <div>销售价格:</div>
        <div>
          <div style="margin:50px 0 0 0;display:flex;">
            <div style="margin:3px 10px 0 0;width:200px;">成人销售价格:</div>
            <!-- <el-input size="mini"  placeholder="请输入大编码"> -->
            <el-input placeholder="请输入成人销售价格" v-model="ruleForm.aldultPrice">
            </el-input>

          </div>
          <div style="margin:50px 0 0 0;display:flex;">
            <div style="margin:3px 10px 0 0;width:200px;">儿童销售价格:</div>
            <!-- <el-input size="mini"  placeholder="请输入大编码"> -->
            <el-input placeholder="请输入儿童销售价格" v-model="ruleForm.childPrice">
            </el-input>

          </div>
          <div style="margin:50px 0 0 0;display:flex;">
            <div style="margin:3px 10px 0 0;width:200px;">婴儿销售价格:</div>
            <!-- <el-input size="mini"  placeholder="请输入大编码"> -->
            <el-input placeholder="请输入婴儿销售价格" v-model="ruleForm.babyPrice">
            </el-input>

          </div>
          <div style="margin:50px 0 0 0;display:flex;">
            <div style="margin:3px 10px 0 0;width:150px;">最晚出票时间:</div>
            <!-- <el-input size="mini"  placeholder="请输入大编码"> -->
            <el-date-picker value-format="yyyy-MM-dd HH:mm:ss" v-model="ruleForm.latestTicketingTime" type="datetime"
              placeholder="选择最晚出票时间">
            </el-date-picker>
          </div>
        </div>
      </div>
    </div>
    <!-- 发票凭证 -->
    <div style="margin:20px 0 0 0">
      <div style="display:flex;">
        <div>发票凭证：</div>
        <el-radio-group v-model="radio" @change="changeradio">
          <el-radio label="1">需要</el-radio>
          <el-radio label="2">不需要</el-radio>
        </el-radio-group>
      </div>

    </div>
    <!-- 发票信息 -->
    <div v-if="this.changeradioList=='1'">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" size="mini">
        <div style="display:flex">
          <el-form-item label="发票类型" prop="type" style="display:flex;margin:0 50px 0 0">
            <el-radio-group v-model="radioinvoice" @change="radioinvoiceList">
              <el-radio label="personal">个人</el-radio>
              <el-radio label="company">企业</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="发票抬头" prop="name" style="display:flex;">
            <el-input v-model="ruleForm.Invoice"></el-input>
          </el-form-item>
          <el-form-item label="手机" prop="phone" style="display:flex;">
            <el-input v-model="ruleForm.phone"></el-input>
          </el-form-item>
        </div>
        <div style="display:flex" v-if="this.radioinvoiceListType=='company'">
          <el-form-item label="电子邮箱" prop="email" style="display:flex;">
            <el-input v-model="ruleForm.Email"></el-input>
          </el-form-item>
          <el-form-item label="发票金额" prop="amount" style="display:flex;">
            <el-input v-model="ruleForm.InvoiceAmount"></el-input>
          </el-form-item>
          <el-form-item label="联系人" prop="contactName" style="display:flex;">
            <el-input v-model="ruleForm.contact"></el-input>
          </el-form-item>
          <el-form-item label="纳税人识别号" prop="number" style="display:flex;">
            <el-input v-model="ruleForm.coordinatesgd"></el-input>
          </el-form-item>
          <!-- <el-form-item label="备注说明" style="display:flex;">
          <el-input   type="textarea"
             :rows="2" v-model="ruleForm.name"></el-input>
        </el-form-item> -->
        </div>
      </el-form>
    </div>

    <div style="margin:30px 0 0 45% ;">
      <el-button size="medium" @click="uploadticket" type="primary">提交</el-button>
      <el-button size="medium" @click="returnticket" type="primary">返回</el-button>

    </div>
  </div>
</template>

<script>
  export default {
    name: "orderimport",
    data() {
      return {

        //  format: "yyyy-MM-dd HH:mm:ss",
        arr: [],
        // 手动输入数组
        Passengerinformation: [{
          name: "",
          type: "",
          sex: "",
          birthday: "",
          citizenship: "",
          phone: "",
          documentsDate: "",
          idno: "",
          idtype: "",
          ticketNum: ""
        }],
        // 发票类型
        radioinvoice: 'personal',
        radioinvoiceListType: "",
        // 去程
        outbound: {
          airline: "",
          setOff: "",
          arrive: "",
          flightNumber: "",
          departureTime: "",
          arrivalTime: "",
          position: ""
        },
        // 返程
        journey: {
          airline: "",
          setOff: "",
          arrive: "",
          flightNumber: "",
          departureTime: "",
          arrivalTime: "",
          position: ""
        },
        // 乘机人信息
        travelerVoList: [],
        // 国籍
        nationality: [{
            value: "中国",
            label: "中国",
          },
          {
            value: "香港",
            label: "香港",
          },
        ],
        // 证件类型
        mold: [{
            value: "ID_CARD",
            label: "身份证",
          },
          {
            value: "MILITARY_ID",
            label: "军人证",
          },
          {
            value: "PASSPORT",
            label: "护照",
          },
          {
            value: "MTPFHKAMR",
            label: "港澳居民来往内地通行证",
          },
          {
            value: "MTPFTR",
            label: "台湾居民来往大陆通行证",
          },
          {
            value: "RPFHKMATR",
            label: "港澳台居民居住证",
          },
          {
            value: "PRICFF",
            label: "外国人永久居留身份证",
          },
          {
            value: "HKAMP",
            label: "港澳通行证",
          },
          {
            value: "ACCOUNT_BOOK",
            label: "户口本",
          },
          {
            value: "BIRTH_CERTIFICATE",
            label: "出生证明",
          },
          {
            value: "TAIWAN_PASS",
            label: "台湾通行证",
          },
        ],
        // 性别
        gender: [{
            value: 'male',
            label: '男'
          },
          {
            value: 'female',
            label: '女'
          },
        ],
        // 乘客类型
        Passengerstype: [{
            value: '成人',
            label: '成人'
          },
          {
            value: '儿童',
            label: '儿童'
          },
        ],
        // 校验
        // rules: {
        //   name: [{ required: true, message: "请输入发票抬头", trigger: "blur" }],
        // },
        // 基本数据
        ruleForm: {
          coding: "",
          pnr: "",
          aldultPrice: "",
          childPrice: "",
          babyPrice: "",
          latestTicketingTime: "",
          whetherBill: "",
          refundRebook: "",
          luggage: "",
          // 发票信息
          Invoice: "",
          Email: "",
          InvoiceAmount: "",
          contact: "",
          phone: "",
          PassengerinList: {},
          invoiceType: "",
          coordinatesgd: "",

        },
        changeradioList: "2",
        textarea: "",
        radio: "2",
        format: "yyyy-MM-dd",
        tableData: [],
        orderquery: {},
        // 会员信息查询
        members: {
          customerName: "",
          customerCard: "",
          customerPhone: "",
        },
      };
    },
    methods: {

      // 返回按钮
      returnticket() {
        this.$router.go(-1);
      },
      insert(e) {
        if (!e.target.value.trim()) return alert("内容不能为空")

      },
      // 添加乘车人
      addRiders() {
        console.log(this.Passengerinformation.length)

        for (let i = 0; i < this.Passengerinformation.length; i++) {
          this.arr.push(this.Passengerinformation[i])
        }
        console.log(this.arr)
        console.log(this.Passengerinformation)
      },
      // 发票类型
      radioinvoiceList(row) {
        console.log(row)
        this.radioinvoiceListType = row
      },
      // 导入PNR按钮
      importPNR() {
        if (this.ruleForm.pnr == '') {
          this.$message({
            message: '请输入pnr进行查询',
            type: 'warning'
          })
        } else {
          this.getselectPNR()
        }
      },
      // 提交按钮 this.getselectIflightOrder()
      uploadticket() {

        // console.log(this.travelerVoList.length>=1)
        // debugger
        // console.log(this.outbound.departureTime)
        // debugger
        // console.log(this.travelerVoList)
        if (this.members.customerPhone == '' || this.members.customerCard == '' || this.members.customerName == '') {
          this.$message({
            message: '请查询会员信息',
            type: 'warning'
          });
        } else if (this.outbound.airline == '') {
          this.$message({
            message: '去程航司不能为空',
            type: 'warning'
          });
        } else if (this.outbound.setOff == '') {
          this.$message({
            message: '去程出发地机场不能为空',
            type: 'warning'
          });
        } else if (this.outbound.arrive == '') {
          this.$message({
            message: '去程到达地机场不能为空',
            type: 'warning'
          });
        } else if (this.outbound.flightNumber == '') {
          this.$message({
            message: '去程航班号不能为空',
            type: 'warning'
          });
        } else if (this.outbound.departureTime == '') {
          this.$message({
            message: '去程起飞时间不能为空',
            type: 'warning'
          });
        } else if (this.outbound.arrivalTime == '') {
          this.$message({
            message: '去程到达时间不能为空',
            type: 'warning'
          });
        } else if (this.outbound.position == '') {
          this.$message({
            message: '去程舱位不能为空',
            type: 'warning'
          });
        } else if (this.ruleForm.pnr == '') {
          this.$message({
            message: 'PNR不能为空',
            type: 'warning'
          });
        } else if (this.ruleForm.coding == '') {
          this.$message({
            message: '大编码不能为空',
            type: 'warning'
          });
        } else if (this.ruleForm.pnrcontent == '') {
          this.$message({
            message: 'PNR内容消息不能为空',
            type: 'warning'
          });
        } else if (this.ruleForm.refundRebook == '') {
          this.$message({
            message: '退改签规则不能为空',
            type: 'warning'
          });
        } else if (this.ruleForm.luggage == '') {
          this.$message({
            message: '行李规则不能为空',
            type: 'warning'
          });
        } else if (this.ruleForm.latestTicketingTime == '') {
          this.$message({
            message: '最晚出票时间不能为空',
            type: 'warning'
          });
        } else if (this.ruleForm.aldultPrice == '') {
          this.$message({
            message: '成人销售价不能为空',
            type: 'warning'
          });
        } else if (this.ruleForm.childPrice == '') {
          this.$message({
            message: '儿童销售价不能为空',
            type: 'warning'
          });
        } else if (this.ruleForm.babyPrice == '') {
          this.$message({
            message: '婴儿销售价格不能为空',
            type: 'warning'
          });
        } else {



          if (this.travelerVoList.length >= 1) {
            // console.log('111')
            // console.log(this.arr.length)
            // console.log(this.arr.length>=1)
            if (this.travelerVoList[0].name == '') {
              this.$message({
                message: '乘机人姓名不能为空',
                type: 'warning'
              });
            } else if (this.travelerVoList[0].name == '') {
              this.$message({
                message: '乘机人姓名不能为空',
                type: 'warning'
              });
            } else if (this.travelerVoList[0].idno == '') {
              this.$message({
                message: '乘机人证件号不能为空',
                type: 'warning'
              });
            } else if (this.travelerVoList[0].birthday == '') {
              this.$message({
                message: '乘机人生日不能为空',
                type: 'warning'
              });
            } else if (this.travelerVoList[0].sex == '') {
              this.$message({
                message: '性别不能为空',
                type: 'warning'
              });
            } else if (this.travelerVoList[0].type == '') {
              this.$message({
                message: '乘客类型不能为空不能为空',
                type: 'warning'
              });
            } else if (this.travelerVoList[0].citizenship == '') {
              this.$message({
                message: '国籍不能为空',
                type: 'warning'
              });
            } else if (this.travelerVoList[0].documentsDate == '') {
              this.$message({
                message: '乘机人证件有效期不能为空',
                type: 'warning'
              });
            } else if (this.travelerVoList[0].idtype == '') {
              this.$message({
                message: '证件类型不能为空',
                type: 'warning'
              });
            } else if (this.travelerVoList[0].phone == '') {
              this.$message({
                message: '乘机人手机号不能为空',
                type: 'warning'
              });
            } else if (this.travelerVoList[0].ticketNum == '') {
              this.$message({
                message: '票号不能为空',
                type: 'warning'
              });
            } else {
              if (this.arr.length >= 1) {
                if (this.arr[0].name == '') {
                  this.$message({
                    message: '乘机人姓名不能为空',
                    type: 'warning'
                  });
                } else if (this.arr[0].name == '') {
                  this.$message({
                    message: '乘机人姓名不能为空',
                    type: 'warning'
                  });
                } else if (this.arr[0].idno == '') {
                  this.$message({
                    message: '乘机人证件号不能为空',
                    type: 'warning'
                  });
                } else if (this.arr[0].birthday == '') {
                  this.$message({
                    message: '乘机人生日不能为空',
                    type: 'warning'
                  });
                } else if (this.arr[0].sex == '') {
                  this.$message({
                    message: '性别不能为空',
                    type: 'warning'
                  });
                } else if (this.arr[0].type == '') {
                  this.$message({
                    message: '乘客类型不能为空不能为空',
                    type: 'warning'
                  });
                } else if (this.arr[0].citizenship == '') {
                  this.$message({
                    message: '国籍不能为空',
                    type: 'warning'
                  });
                } else if (this.arr[0].documentsDate == '') {
                  this.$message({
                    message: '乘机人证件有效期不能为空',
                    type: 'warning'
                  });
                } else if (this.arr[0].idtype == '') {
                  this.$message({
                    message: '证件类型不能为空',
                    type: 'warning'
                  });
                } else if (this.arr[0].phone == '') {
                  this.$message({
                    message: '乘机人手机号不能为空',
                    type: 'warning'
                  });
                } else if (this.arr[0].ticketNum == '') {
                  this.$message({
                    message: '票号不能为空',
                    type: 'warning'
                  });
                }
              } else {
                console.log('1111111111111111111111')
                this.getselectIflightOrder()
              }
            }
            // }else if(this.arr.length>=1){
            // console.log("xiaxia----------")
            //  
            // }else{

          } else {
            this.getselectIflightOrder()
            console.log("1111")
          }

        }










      },
      // 创建国际机票
      getselectIflightOrder() {
        console.log(this.Passengerinformation)
        this.showLoading()
        let outboundgo = []
        outboundgo.push(this.outbound)
        let journeyBack = []
        journeyBack.push(this.journey)
        console.log(this.Passengerinformation)
        for (let i = 0; i < this.arr.length; i++) {
          this.travelerVoList.push(this.arr[i])

        }
        console.log(this.PassengerinList)
        // if(this.travelerVoList.length==0){
        //   this.travelerVoList=[
        //     this.PassengerinList
        //   ]
        // }
        this.$axios.getselectIflightOrder({
          pnrVo: {
            coding: this.ruleForm.coding,
            // 去程
            outbound: outboundgo,
            // 返程
            journey: journeyBack,
            // 乘机人信息
            travelerVoList: this.travelerVoList
          },
          pnr: this.ruleForm.pnr,
          // 会员信息
          customerName: this.members.customerName,
          customerCard: this.members.customerCard,
          customerPhone: this.members.customerPhone,
          // 成人价格
          aldultPrice: this.ruleForm.aldultPrice,
          // 儿童
          childPrice: this.ruleForm.childPrice,
          // 婴儿
          babyPrice: this.ruleForm.babyPrice,
          // 最晚出票时间
          latestTicketingTime: this.ruleForm.latestTicketingTime,
          // 是否发票
          whetherBill: this.changeradioList,
          // 退改签规则
          refundRebook: this.ruleForm.refundRebook,
          // 行李规则
          luggage: this.ruleForm.luggage,
          Invoice: this.ruleForm.Invoice,
          Email: this.ruleForm.Email,
          InvoiceAmount: this.ruleForm.InvoiceAmount,
          contact: this.ruleForm.contact,
          phone: this.ruleForm.phone,
          invoiceType: this.radioinvoiceListType,
          coordinatesgd: this.ruleForm.coordinatesgd,
        }).then((res) => {
          this.closeLoading()
          console.log(res)
          if (res.code == '200') {
            this.$router.go(-1)
          } else {
            this.closeLoading()
            this.$message.error('创建订单失败，请核对信息重新创建');
          }
        }).catch((err) => {
          this.closeLoading()
          this.$message.error('创建订单失败，请核对信息重新创建');
        })
      },
      // 通过pnr查询
      getselectPNR() {
        this.showLoading()
        this.$axios.getselectPNR({
          pnr: this.ruleForm.pnr
        }).then((res) => {
          this.closeLoading()
          console.log(res)
          if (res.code == '200') {
            this.$message({
              message: '查询成功',
              type: 'success'
            })
            // 去程
            this.ruleForm = res.data
            console.log(this.ruleForm)
            this.outbound = res.data.outbound[0],
              console.log(this.outbound)
            // 返程
            this.journey = res.data.journey[0],
              console.log(this.journey)
            if (this.journey == undefined) {
              this.journey = {}
            }
            // 乘机人
            let arr = JSON.parse(JSON.stringify(res.data.travelerVoList))
            arr.forEach(item => {
              item.phone = ''
              // 证件有效期
              item.documentsDate = ''
              // 证件类型
              item.idtype = ""
              // 国籍
              item.citizenship = ''
            });
            this.travelerVoList = arr
            console.log(this.travelerVoList)
          } else {
            this.closeLoading()
            this.$message.error('输入有误，请输入正确pnr进行查询');
          }
        }).catch((err) => {
          this.closeLoading()
          this.$message.error('输入有误，请输入正确pnr进行查询');
        })
      },
      // 会员查询按钮
      searchorderimport() {
        if (
          this.members.customerPhone != "" ||
          this.members.customerName != "" ||
          this.members.customerCard != ""
        ) {
          this.getcustomerId();
        } else {
          this.$message({
            message: "请通过姓名、手机号、卡号任一选项查询会员信息",
            type: "warning",
          });
        }
      },
      // 查询会员接口
      getcustomerId() {
        this.$axios
          .getcustomerId({
            customerName: this.members.customerName,
            customerCard: this.members.customerCard,
            customerPhone: this.members.customerPhone,
          })
          .then((res) => {
            console.log(res);
            if (res.code == "200") {
              this.members = res.data;
            } else {
              this.$message({
                message: "输入信息不正确，请核对后重新查询",
                type: "warning",
              });
            }
          });
      },
      // submitForm(formName) {
      //   this.$refs[formName].validate((valid) => {
      //     if (valid) {
      //       alert("submit!");
      //     } else {
      //       console.log("error submit!!");
      //       return false;
      //     }
      //   });
      // },
      // 发票
      changeradio(row) {
        console.log(row);
        if (row == '1') {
          row = true
        } else {
          row = false
        }
        this.changeradioList = row;
        console.log(this.changeradioList)
      },
      //跳出
      closeLoading() {
        this.tableLoading.close();
      },
      //进入
      showLoading() {
        this.tableLoading = this.$loading({
          text: "拼命加载数据中", //显示在加载图标下方的加载文案
          spinner: "el-icon-loading", //自定义加载图标类名
          background: "rgba(0, 0, 0, 0.4)", //遮罩层颜色
          target: document.querySelector("#table"), //loadin覆盖的dom元素节点
        });
      },
    },
    mounted() {},
  };
</script>

<style scoped>
  .orderimport {
    margin: 20px;
  }

  .middle {
    margin-top: 50px;
    display: flex;
    justify-content: space-between;
  }

  .right {
    margin-right: 50px;
    display: flex;
    /* justify-content: space-between; */
  }
</style>